package com.neusoft.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class CommonUtil {

    public static String getCurrentDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date(System.currentTimeMillis());
        String ans = formatter.format(date).toString();
        return ans;
    }

    public static String getPreviousDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -7);
        Date previousDate = calendar.getTime();
        String ans = formatter.format(previousDate);
        return ans;
    }

    public static String getExpirationDate() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -6);
        Date previousDate = calendar.getTime();
        String ans = formatter.format(previousDate);
        return ans;
    }

    public static void main(String[] args) {
        getCurrentDate();
    }
}
